package com.paw.file.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.paw.file.entity.FileInfo;
import com.paw.file.mapper.FileInfoMapper;
import com.paw.file.service.IFileInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 文件信息 服务实现类
 * </p>
 *
 * @author Rubble
 * @since 2020-04-24
 */
@Service
public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements IFileInfoService {

    @Autowired
    private FileInfoMapper fileInfoMapper;

    @Override
    public FileInfo findByMd5(String md5) {
        FileInfo fileInfo = new FileInfo();
        fileInfo.setMd5(md5);
        List<FileInfo> fileInfos = fileInfoMapper.selectList(new QueryWrapper<>(fileInfo));
        FileInfo result = fileInfos.isEmpty()? null: fileInfos.get(0);
        return result;
    }
}
